home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CDsupport / IDer / IDer.s < prev    next >
Text File  |  1997-02-18  |  8KB  |  348 lines

  1.     Section    IDer,Code
  2.     OPT    !
  3.     MACHINE    68000
  4.  
  5.     NOLIST
  6.     IncDir    Include:
  7.     Include    mysystem.i
  8.  
  9.     Include    libraries/asl.i
  10.     Include    libraries/xpk.i
  11.  
  12.     Include    lib/asl_lib.i
  13.     Include    lib/icon_lib.i
  14.     Include    lib/wb_lib.i
  15.     Include    lib/xpkmaster_lib.i
  16.  
  17.     Include    IDer.i
  18.     Include    Applications:Development/lib/wbpath.i
  19.  
  20. OPENLIBRARY    MACRO    lib,ver
  21.     Lea    (\1Library,PC),A1    ;intuition library is needed if we are
  22.     Moveq    #\2,D0        ;running from workbench.  It's easier to
  23.     CALL    OpenLibrary,EXEC    ;open it now when we can trash registers
  24.     Move.L    D0,_\1Base        ;than trying to work around keeping some
  25.     Beq    CloseDown        ;values safer later on
  26.     ENDM
  27.  
  28. CLOSELIBRARY    MACRO    Lib
  29.     Move.L    (_\1Base,PC),A1        ;better close this to keep the masses happy
  30.     Cmp.L    #0,A1
  31.     Beq.S    .No\1
  32.     CALL    CloseLibrary,EXEC
  33. .No\1
  34.     ENDM
  35.  
  36.     LIST
  37.  
  38. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  39. Start:    Move.L    $4.w,A6
  40.     Move.L    A6,_EXECBase        ;for use with FASTMEM
  41.  
  42. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  43.     Sub.L    A1,A1
  44.     CALL    FindTask
  45.     Move.L    D0,A4
  46.     Tst.L    pr_CLI(A4)
  47.     Bne    .FromCLI
  48.  
  49.     Include    Routines/WBHandler.s
  50.  
  51. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  52. .FromCLI    Lea    DOSLibrary(PC),A1
  53.     Moveq    #37,D0        ;we need Kickstart 2.04 or better
  54.     CALL    OpenLibrary
  55.     Move.L    D0,_DOSBase
  56.     Beq    BadDOS
  57.  
  58.     OPENLIBRARY    INTUI,0
  59.  
  60.     Move.W    #RDARGERR,_ErrorCode
  61.     Move.L    #ArgTemplate,D1        ;template of arguments available
  62.     Move.L    #_FileName,D2        ;start of table to store argument values
  63.     Moveq    #0,D3        ;no custom RDA structure this time
  64.     CALL    ReadArgs,DOS        ;process the commandline
  65.     Move.L    D0,_ArgRDA
  66.     Beq    CloseDown        ;bug out if the commandline failed
  67.  
  68. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  69. WBReEnter:    Include    Routines/GetConfig.s
  70.     Include    Routines/GetFileName.s
  71. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  72.     Cmp.W    #ARGS_NOARGS,_ArgMode
  73.     Beq.S    .AppIcon
  74.  
  75.     Bsr    DoFiles
  76.     Bra    CloseDown
  77.  
  78. .AppIcon    Tst.B    _UseAppIcon
  79.     Beq    CloseDown
  80.  
  81.     Include    Routines/AppIcon.s
  82.  
  83. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  84. CloseDown:    Bsr    ErrorHandler
  85.  
  86.     Move.L    _ConfigHandle(PC),D1    ;was there an error during the config loading
  87.     Tst.L    D1
  88.     Beq.S    .NoConfig
  89.     CALL    Close,DOS
  90. .NoConfig
  91.     Move.L    _FileHandle(PC),D1    ;how about during loading our file to view
  92.     Tst.L    D1
  93.     Beq.S    .NoFile
  94.     CALL    Close,DOS
  95. .NoFile
  96.     Move.L    _Requestor(PC),A0    ;free up requestor structure
  97.     Cmp.L    #0,A0
  98.     Beq.S    .NoASLReq
  99.     CALL    FreeAslRequest,ASL
  100. .NoASLReq
  101.     Move.L    _OutputBuffer(PC),A1    ;clean up the memory allocated to hold the config file
  102.     Move.L    _OutputBufLen(PC),D0
  103.     Cmp.L    #0,A1
  104.     Beq.S    .NoFileMemory
  105.     CALL    FreeMem,EXEC
  106. .NoFileMemory
  107.     Move.L    _ConfigMem(PC),A1    ;clean up the memory allocated to hold the config file
  108.     Move.L    _ConfigSize(PC),D0
  109.     Cmp.L    #0,A1
  110.     Beq.S    .NoConfigMemory
  111.     CALL    FreeMem,EXEC
  112. .NoConfigMemory
  113.     Move.L    _ArgRDA(PC),D1        ;free up the ReadArgs structure
  114.     Tst.L    D1
  115.     Beq.S    .NoRDA
  116.     CALL    FreeArgs,DOS
  117. .NoRDA
  118.     Move.L    _IconObject(PC),A0    ;was there an error while working with the icons/tooltypes
  119.     Cmp.L    #0,A0
  120.     Beq.S    .NoDiskObject
  121.     CALL    FreeDiskObject,ICON
  122. .NoDiskObject
  123.     Move.L    _AppIconActual(PC),A0    ;was there an error while working with the icons/tooltypes
  124.     Cmp.L    #0,A0
  125.     Beq.S    .NoAppIcon
  126.     CALL    RemoveAppIcon,WB
  127. .NoAppIcon
  128.     Move.L    _AppMsg(PC),A1
  129.     Cmp.L    #0,A1
  130.     Beq.S    .NoAppMsg
  131.     CALL    ReplyMsg,EXEC
  132. .NoAppMsg
  133.     Move.L    _AppMsgPort(PC),A0    ;was there an error while working with the appicon
  134.     Cmp.L    #0,A0
  135.     Beq.S    .NoMsgPort
  136.     CALL    DeleteMsgPort,EXEC
  137. .NoMsgPort
  138.     Move.L    _OldDirectory(PC),D1
  139.     Tst.L    D1
  140.     Beq.S    .NoDirectory
  141.     CALL    CurrentDir,DOS
  142. .NoDirectory
  143.     CLOSELIBRARY    XPK
  144.     CLOSELIBRARY    ASL
  145.     CLOSELIBRARY    WB
  146.     CLOSELIBRARY    ICON
  147.     CLOSELIBRARY    INTUI
  148.     CLOSELIBRARY    DOS
  149.  
  150.     Tst.L    _WBMessage        ;were we launched from Workbench?
  151.     Beq.S    .NoWBMsg
  152.     CALL    Forbid,EXEC
  153.     Move.L    _WBMessage(PC),A1
  154.     CALL    ReplyMsg
  155. .NoWBMsg
  156.     Moveq    #0,D0        ;no error codes
  157.  
  158.     Tst.W    _ErrorCode
  159.     Beq.S    .NoErrors
  160.     Moveq    #RETURN_ERROR,D0
  161. .NoErrors    Rts
  162.  
  163. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  164.     Include    Routines/DoFiles.s
  165.     Include    Routines/ParseConfig.s
  166.     Include    Routines/ProcessFlags.s
  167.     Include    Routines/Routines.s
  168.     Include    Routines/ErrorHandler.s
  169.     Include    Routines/Cleanup.s
  170.     Include    Routines/BadDOS.s
  171.  
  172. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  173. IDerPrefs:    Dc.B    'ENV:IDer.prefs',0
  174. DOSLibrary:    DOSNAME
  175. ASLLibrary:    ASLNAME
  176. XPKLibrary:    XPKMASTERNAME
  177. ICONLibrary:    ICONNAME
  178. INTUILibrary:    INTUITIONNAME
  179. WBLibrary:    WORKBENCHNAME
  180. Version:    Dc.B    '$VER: IDer 1.05 (15.1.95)',0
  181. SearchString:    Dc.B    '  =',0
  182. ArgTemplate:    Dc.B    'FILENAME/M,'
  183. CrunchedTT:    Dc.B    'NOCRUNCHED/S,'
  184. ConfigTT:    Dc.B    'CONFIG/K',0
  185. AppIconTT:    Dc.B    'APPICON',0,0
  186. AppNameTT:    Dc.B    'APPNAME',0
  187. Ok:    Dc.B    'OK',0
  188. IDerTxt:    Dc.B    'IDer',0
  189. Info:    Dc.B    '.info',0
  190. FReqTitle:    Dc.B    'Select file to load...',0
  191. ErrorHeader:    Dc.B    'There was an error %s%s%s\n',0
  192. ErrProcessing:    Dc.B    'processing the command line',0
  193. ErrOpening:    Dc.B    'opening \'',0
  194. ErrReading:    Dc.B    'reading \'',0
  195. ErrMemory:    Dc.B    'allocating memory to load',0
  196. ErrASLLib:    Dc.B    'asl.library\' v38+',0
  197. ErrASLReq:    Dc.B    'allocating a file requestor',0
  198. ErrEndOfCfg:    Dc.B    'finding a suitable CLASS entry',0
  199. ErrXPK:    Dc.B    'decrunching using XPK.\n',0
  200. ErrCreating:    Dc.B    'creating the ',0
  201. ErrCustom:    Dc.B    '\ncustom '
  202. ErrAppIcon:    Dc.B    'AppIcon',0
  203. ErrDefault:    Dc.B    '.  Using \'IDer.info\' image',0
  204. ErrCloseQuote:    Dc.B    '\'',0
  205. ErrDOS:    Dc.B    'You need at least Kickstart 2.04 to use IDer.\n',0
  206. AboutText:    Dc.B    'Copyright © 1995  Eclipse Software\n\n'
  207.     Dc.B    'This program is classified as\n'
  208.     Dc.B    'Shareware, and a donation of $10\n'
  209.     Dc.B    'is suggested if used reguarly.',0
  210. AboutGads:    Dc.B    'Select|Quit|Cancel',0
  211.     Even
  212.  
  213. _EXECBase:    Dc.L    0
  214. _DOSBase:    Dc.L    0
  215. _ASLBase:    Dc.L    0
  216. _XPKBase:    Dc.L    0
  217. _ICONBase:    Dc.L    0
  218. _INTUIBase:    Dc.L    0
  219. _WBBase:    Dc.L    0
  220.  
  221. _WBMessage:    Dc.L    0
  222. _WBPaths:    Dc.L    0
  223. _IconObject:    Dc.L    0
  224.  
  225. _ToolTypes:    Dc.L    0
  226. _OldDirectory:    Dc.L    0
  227.  
  228. _AppIcon:    Dc.L    0
  229. _AppName:    Dc.L    IDerTxt
  230. _AppIconX:    Dc.L    0
  231. _AppIconY:    Dc.L    0
  232. _AppIconActual:    Dc.L    0
  233. _AppMsgPort:    Dc.L    0
  234. _Signal:    Dc.L    0
  235. _AppMsg:    Dc.L    0
  236.  
  237. _UseAppIcon:    Dc.B    0
  238.     Dc.B    0    ;pad
  239.  
  240. _ArgRDA:    Dc.L    0
  241. _FileName:    Dc.L    0
  242. _Crunched:    Dc.L    0
  243. _Config:    Dc.L    0
  244.  
  245. _FileHandle:    Dc.L    0
  246. _FileData:    Dc.L    FileData
  247. _FilePart:    Dc.L    0
  248.  
  249. _CurrentName:    Dc.L    0
  250. _ArgMode:    Dc.W    ARGS_NOARGS
  251. _LoopCount:    Dc.W    0
  252.  
  253. _XPKTags:    Dc.L    XPK_InFH,0
  254.     Dc.L    XPK_GetOutBuf,_OutputBuffer
  255.     Dc.L    XPK_GetOutLen,_OutputLength
  256.     Dc.L    XPK_GetOutBufLen,_OutputBufLen
  257.     Dc.L    XPK_PassThru,-1
  258.     Dc.L    XPK_GetError,XPKErrorBuffer
  259.     Dc.L    TAG_DONE
  260.  
  261. _OutputBuffer:    Dc.L    0
  262. _OutputLength:    Dc.L    0
  263. _OutputBufLen:    Dc.L    0
  264.  
  265. _ErrorCode:    Dc.W    0
  266.  
  267. ErrTable:    Dc.L    ErrProcessing,0,0        ;commandline error
  268. _CfgErr:    Dc.L    ErrOpening,IDerPrefs+4,ErrCloseQuote    ;opening config
  269.     Dc.L    ErrMemory,IDerPrefs+4,ErrCloseQuote    ;config memory
  270.     Dc.L    ErrReading,IDerPrefs+4,ErrCloseQuote    ;reading config
  271. _ErrFN1:    Dc.L    ErrOpening,0,ErrCloseQuote        ;opening datafile
  272. _ErrFN2:    Dc.L    ErrReading,0,ErrCloseQuote        ;reading datafile
  273.     Dc.L    ErrOpening,ErrASLLib,0        ;no asl library
  274.     Dc.L    ErrASLReq,0,0            ;no asl requestor
  275.     Dc.L    ErrEndOfCfg,0,0            ;no entry in config
  276.     Dc.L    ErrXPK,XPKErrorBuffer,0        ;problem with XPK routines
  277.     Dc.L    ErrCreating,ErrAppIcon,ErrDefault    ;couldn't create AppIcon
  278.     Dc.L    ErrCreating,ErrCustom,ErrDefault    ;couldn't create custom AppIcon
  279.  
  280. _ConfigMem:    Dc.L    0
  281. _ConfigSize:    Dc.L    0
  282. _ConfigHandle:    Dc.L    0
  283. _ConfigCurPos:    Dc.L    0
  284.  
  285. _OffsetVal:    Dc.L    0
  286.  
  287. _Requestor:    Dc.L    0
  288. _ASLTags:    Dc.L    ASLFR_RejectIcons,TRUE
  289.     Dc.L    ASLFR_DoMultiSelect,TRUE
  290.     Dc.L    ASLFR_TitleText,FReqTitle
  291.     Dc.L    TAG_DONE
  292.  
  293. _esReq:    Dc.L    EasyStruct_SIZEOF
  294.     Dc.L    0
  295.     Dc.L    Version+6
  296.     Dc.L    0
  297.     Dc.L    0
  298.  
  299. _Mode:    Dc.B    0
  300. _Insensitive:    Dc.B    0
  301. _Quote:    Dc.B    0
  302. _Successful:    Dc.B    0
  303.  
  304. EntryTable:    Dc.L    _Class,_Suffix,_Name,_Offset,_Flags
  305.     Dc.L    -1,_Stack,_Pri,-1
  306.  
  307. _Class    Dc.L    0
  308.     Dc.B    'CLASS=',0
  309.     Even
  310. _Suffix    Dc.L    0
  311.     Dc.B    'SUFFIX=',0
  312.     Even
  313. _Name    Dc.L    0
  314.     Dc.B    'NAME=',0
  315.     Even
  316. _Offset    Dc.L    0
  317.     Dc.B    'OFFSET=',0
  318.     Even
  319. _Flags    Dc.L    0
  320.     Dc.B    'FLAGS=',0
  321.     Even
  322. _Stack    Dc.L    0
  323.     Dc.B    'STACK=',0
  324.     Even
  325. _Pri    Dc.L    0
  326.     Dc.B    'PRI=',0
  327.     Even
  328. _Action    Dc.L    0
  329.     Dc.B    'ACTION=',0
  330.     Even
  331.  
  332. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  333.     Section    IDerData,BSS
  334. CommandLine:    Ds.B    1024
  335.  
  336. FileName:    Ds.B    1024
  337. FileData:    Ds.B    IDData
  338.  
  339. ConfigLine:    Ds.B    1024
  340. ParseData:    Ds.B    256
  341. WorkData:    Ds.B    128
  342. XPKErrorBuffer:    Ds.B    XPKERRMSGSIZE
  343.  
  344. AppIconName:    Ds.B    32
  345. ConfigName:    Ds.B    128
  346.  
  347. _SystemTags:    Ds.L    (MaxTags*2)+2
  348.